<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue组件</title>
    <script src="https://unpkg.com/vue@next"></script>
    <!-- 
        1.如果父组件中的属性名字使用-隔开,子组件接收的时候,应该使用驼峰接收
        2.单项数据流的概念,父组件可以向子组件传递数据,但是子组件不可以修改父组件数据
        3.可以接收过来父组件数据的初始值
     -->
</head>
<body>
    <div id="root"></div>
    <script>
        // vue的生命周期函数
        const app = Vue.createApp({
            data() {
                return {
                    params: {
                        a1: 1,
                        b1: 2,
                        c3: 3,
                        d3: 4,
                    },
                    num: 1
                }
            },
            template: `
                <div> 
                    <counter :count="num" />
                </div>
            `
        });
        app.component('test',{
            props: ['a1','b1'],
            data() {
                return {
                   myCount: this.count
                }
            },
            template:
            `
                <div>{{a1}}-->{{b1}}</div>
            `
        });
        app.component('counter',{
            props: ['count'],
            data() {
                return {
                   myCount: this.count
                }
            },
            template:`
            <div @click="myCount+=1"> {{myCount}}</div>
            `
        });
        const vm = app.mount('#root');
    </script>
</body>
</html>